/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2023 —10 —13
 * Time: 9:54
 */
public class test_10_13 {

    /*
    //遍历数组
    *//*
    两种方式
    1：for循环去写
    2:foreach 去遍历数组
    3:区别，for循环遍历数组时有下标，foreach没有，
    如果想对数组中单个元素做处理就用for循环
     *//*
    public static void main(String[] args) {
        int[] array = new int[] {1,2,3,4};
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]);
        }
        System.out.println( );
        for (int x : array) {
            System.out.print(x);
        }
    }
    */

    /*
    //两个数组之间进行相互赋值
    public static void main(String[] args) {
        //数组是一种引用类型

        int array1 [] = new int[3];//数组长度为3
        //初始化一下
        array1 [0] = 1;
        array1 [1] = 2;
        array1 [2] = 3;
        for (int x:array1) {
            System.out.print(x + " ");
        }
        System.out.println();

        int array2 [] = new int[]{100,202,300,400};
        for (int i = 0; i < array2.length; i++) {
            System.out.print(array2[i] + " ");
        }


        System.out.println();

        array1 = array2;  //  array1所指对象被系统回收
        //  array1现存储的是array2的地址，所指对象是array2数组所指对象
        array1 [0] = 10;
        array1 [1] = 20;
        array2 [3] = 40;
        for (int x:array2) {
            System.out.print(x + " ");
        }
    }
    */


    public static void main(String[] args) {
        //空指针异常，当前引用不指向任何对象
        int array1[] = null;
        System.out.println(array1.length);
    }



}
